import { GlobalState } from "@/redux/interface";
import type { SizeType } from "antd/lib/config-provider/SizeContext"
import { createSlice } from "@reduxjs/toolkit"

const globalState: GlobalState = {
    token:"",
    userInfo:"",
    assemblySize:"middle",
    language:"",
    theme:"default"
}

const globalSlice = createSlice({
    name: "global",
    initialState: globalState,
    reducers: {
        setToken(state: GlobalState, {payload}) {
            state.token = payload
        },
        setUserInfo(state: GlobalState, {payload}) {
            state.userInfo = payload
        },
        setAssemblySize(state: GlobalState, {payload}) {
            state.assemblySize = payload
        },
        setLanguage(state:GlobalState, {payload}) {
            state.language = payload
        },
        setTheme(state:GlobalState, {payload}) {
            state.theme = payload
        }
    }
})

export const {setToken, setUserInfo, setAssemblySize, setLanguage, setTheme} = globalSlice.actions
export default globalSlice.reducer